import AudDialog, { AudDialogShowParams } from '@/pages/components/Aud/AudDialog';
import React, { useEffect, useImperativeHandle, useRef } from 'react';
import { useState } from 'react';


const PhaseDeleteDialog: React.FC<any> = React.forwardRef((props: any, ref) => {
  const [visible, setVisible] = useState<boolean>(false);
  const diaParams = useRef<AudDialogShowParams & any>();

  // 自定义方法
  useImperativeHandle(ref, () => ({
    show: async (params: AudDialogShowParams) => {
      diaParams.current = params;
      setVisible(true);
    },
    close: () => { setVisible(false) }
  }));

  return (
    <>
      <AudDialog
        ref={ref}
        visible={visible}
        title={diaParams.current?.args?.title}
        width={500}
        height={230}
        {...props}
        showCancelButton={true}
        showOkButton={true}
        onOK={() => {
          if (diaParams.current?.okCallback) {
            diaParams.current?.okCallback('', '');
          }
          setVisible(false)
        }}
        onCancel={() => {
          setVisible(false);
          if (diaParams.current?.cancelCallback) {
            diaParams.current?.cancelCallback();
          }
        }}
        onHiding={() => {
          setVisible(false);
          if (diaParams.current?.cancelCallback) {
            diaParams.current?.cancelCallback();
          }
        }}
      >
        <div>
          <p>确定要删除：</p>
          {/* diaParams.current?.args?.HSXMLXBH */}
          {
            diaParams.current?.args?.HSXMLXBH ?
              <p style={{ marginLeft: '20px' }}>【辅助账】{diaParams.current?.args?.Name}</p>
              :
              <p style={{ marginLeft: '20px' }}>{diaParams.current?.args?.Name}</p>
          }

        </div>
      </AudDialog>

    </>
  );
});

export default PhaseDeleteDialog;